package po;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 * 利用@Table自定义表
 * @author DELL
 *
 */
@Entity
@Table(name="customers")
public class Customer implements Serializable{
	/**
	 * Entity标明的是一个实体类
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 配置主键
	 */
	public Customer() {
		super();
	}
	public Customer(Integer id, String cname, int age) {
		super();
		this.id = id;
		this.cname = cname;
		this.age = age;
	}
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	//实现增长机制，但是不能使用在Oracle上
	private Integer id;
	/**
	 * 定制字段的长度
	 * 这个是默认都有的注解
	 * 成员变量与列之间的映射
	 */
	@Column(length=12,nullable=false,unique=true)
	private String cname;
	/**
	 * Transient代表的是不会存储到数据库中
	 */
	@Transient
	private int age;
	
	//性别的处理
	@Column(columnDefinition="char(2)")
	private String sex;
	
	//使用java.util全类型
//	@Temporal(TemporalType.DATE)
//	@Temporal(TemporalType.TIME)
	@Temporal(TemporalType.TIMESTAMP)
	@Column(nullable=false)
	private Date bithday;
	
	//图片的处理
	@Lob
	@Basic(fetch=FetchType.LAZY)
	private byte[] image;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getCname() {
		return cname;
	}
	public void setCname(String cname) {
		this.cname = cname;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public byte[] getImage() {
		return image;
	}
	public void setImage(byte[] image) {
		this.image = image;
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public Date getBithday() {
		return bithday;
	}
	public void setBithday(Date bithday) {
		this.bithday = bithday;
	}
	
}